home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
samples
/
Hector1600
/
UnsignedDiv.lis
< prev
next >
Wrap
File List
|
1995-07-26
|
5KB
|
98 lines
0000 1 ;
0000 2 ; ECE463 Unsigned Division
0000 3 ;
0000 4 ; Coded by: Bradford W. Mott
0000 5 ; September 8,1993
0000 6 ;
0000 7
0000 8 .org 0000
0000 9
0000 d8fe 0200 10 move #512,sp
0002 d8f0 0000 11 move #0,r0 ; Init Loop Variable
0004 12
0004 a8f0 0003 13 loop: cmp #num_els,r0 ; Check to see if we're finished
0006 c80d 0011 14 bra finished,.eq
0008 15
0008 d001 16 move r0,r1
0009 0011 17 add r1,r1
000a 18
000a dc17 0100 19 move [r1,data1],r7 ; Get the dividend
000c dc18 0101 20 move [r1,data1+1],r8
000e dc09 0106 21 move [r0,data2],r9 ; Get the divisor
0010 c90b 0008 22 jsr divide ; divide the two numbers
0012 23
0012 d3a1 0109 24 move r10,[r1,result]
0014 d3b1 010a 25 move r11,[r1,result+1]
0016 26
0016 8200 27 inc r0
0017 c80b ffeb 28 bra loop
0019 29
0019 7000 30 finished: stop
001a 31
001a 32
001a c3aa 33 divide: clr r10 ; quot
001b 34
001b d8fd 0010 35 move #16,r13 ; Init the counter
001d 36
001d f100 37 dloop: clc
001e 91aa 38 rol r10 ; quot := Bshl(quot,0,C)
001f 39
001f f100 40 clc
0020 9188 41 rol r8 ; loDvnd := Bshl(loDvnd,0,C)
0021 9177 42 rol r7 ; hiDvnd := Bshl(hiDvnd,C,C)
0022 43
0022 d8fc 0000 44 move #0,r12
0024 c807 0002 45 bra no_flag,.cc
0026 d8fc 0001 46 move #1,r12
0028 47
0028 f000 48 no_flag: sec
0029 8099 49 not r9
002a 1097 50 addc r9,r7 ; hiDvnd := Badd(hiDvnd,Bcom(dvsr),1,C)
002b 51
002b c807 0002 52 bra no_flag2,.cc
002d d8fc 0001 53 move #1,r12
002f 54
002f 8099 55 no_flag2: not r9
0030 a8fc 0001 56 cmp #1,r12
0032 c80d 0004 57 bra set_bit,.eq
0034 58
0034 f100 59 clc
0035 1097 60 addc r9,r7 ; hiDvnd := Badd(hiDvnd,dvsr,0,C)
0036 c80b 0002 61 bra next
0038 62
0038 58fa 0001 63 set_bit: or #1,r10
003a 64
003a 83dd 65 next: dec r13
003b c805 ffe0 66 bra dloop,.ne
003d 67
003d d07b 68 move r7,r11
003e 69
003e d8ef 70 rts ; That's All
003f 71
003f 72
0100 73 .org 256
0100 74
0100 75 num_els: .equ 3
0100 0000 0064 0000 76 data1: .word 0x0000,0x0064,0x0000,0x00FF,0x00FF,0xFFFF
0103 00ff 00ff ffff
0106 000a 000f 0f00 77 data2: .word 0x000A, 0x000F, 0x0F00
0109 78 result: .rmw num_els+num_els
010f 79
dloop 001d 37# 66
. = 010f
divide 001a 22 33#
result 0109 24 25 78#
no_flag 0028 45 48#
set_bit 0038 57 63#
num_els 0003 13 75# 78 78
no_flag2 002f 52 55#
finished 0019 14 30#
loop 0004 13# 28
next 003a 61 65#
data1 0100 19 20 76#
data2 0106 21 77#
13 Symbols
28 References